<?php

/**
 * Class YDashBoard
 */
class YDashBoard extends CWidget
{
	protected $columns = array(
		'column1' => array(
			'class' => 'span5',
			'widgets' => array(
				'welcome',
				'systemInfo',
			),
		),
		'column2' => array(
			'class' => 'span7',
			'widgets' => array(
				'recentlyContent',
			)
		),
	);

	public function run()
	{
		foreach ($this->columns as $column) {
			echo CHtml::openTag('div', array('class' => 'column ' . (isset($column['class']) ? $column['class'] : '')));
			if (!isset($column['widgets'])) {
				continue;
			}
			foreach ((array) $column['widgets'] as $widget) {
				if (is_string($widget)) {
					$this->render($widget);
				} else {
					$widget = Yii::createComponent($widget);
					$widget->run();
				}
			}
			echo CHtml::closeTag('div');
		}
	}

	public function setColumns($columns)
	{
		$this->columns = array_merge($this->columns, $columns);
	}
}